<?php

if($hh->can_access("*") == false){
	$hh->go("index.php?page=main");
	var_dump($hh->can_access("*"));
}
else{
header('Content-Type: text/html; charset=utf-8');
$secili = "panel";
$panel = @$_GET["panel"];
if($panel == ""){
	$secili_link = 1;
	$panel = "my_complaints";
}
elseif($panel == "new_complaint")
	$secili_link = 0;
elseif($panel == "my_complaints")
	$secili_link = 1;
elseif($panel == "watchlist")
	$secili_link = 2;
elseif($panel == "settings")
	$secili_link = 3;
elseif($panel == "configuration")
	$secili_link = 4;
elseif($panel == "categories")
	$secili_link = 5;
elseif($panel == "users")
	$secili_link = 6;
elseif($panel == "all_complaints")
	$secili_link = 7;
elseif($panel == "all_comments")
	$secili_link = 8;
elseif($panel == "articles")
	$secili_link = 9;


$sql_my_complaints = $hh->db_get("*","complaints","author=".(int)$hh->escape($_SESSION['current_user']['id']));
$sql_watchlist = $hh->query("SELECT * FROM `complaints` WHERE watchlist LIKE '%-".$hh->escape($_SESSION['current_user']['id'])."-%'");

$num_complaints = $hh->num_rows($sql_my_complaints);
if($num_complaints == false) $num_complaints = 0;

$num_watchlist = $hh->num_rows($sql_watchlist);
if($num_watchlist == false) $num_watchlist = 0;

$num_article = $hh->num_rows($hh->db_get("*","articles"));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" href="js/jquery-ui-1.8.5.custom/development-bundle/themes/base/jquery.ui.all.css" />
<link rel="stylesheet" href="css/styles.css" />
<style type="text/css">
	.ui-button-text{
		font-size:14px; !important;	
	}
	.ui-dialog-title{
		font-size:16px; !important;	
	}
	.ac_results ul{
	margin:0px;	
	padding:0px;
	}
	.ac_results li{
	padding-top:5px;
	height:25px;
	list-style:none;
	border:1px solid #333;
	background-color:#fff;
	color:#333;
	cursor:default;
		}
</style>
<title><?php echo $_SESSION["current_user"]["username"]; ?> | Panel</title>
<script type="text/javascript" src="js/jquery-1.5.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.5.custom/development-bundle/external/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.core.js"></script>
<script src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.button.js"></script>
<script src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.draggable.js"></script>
<script src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.resizable.js"></script>
<script src="js/jquery-ui-1.8.5.custom/development-bundle/ui/jquery.ui.dialog.js"></script>
<script src="js/jquery.autocomplete.js"></script>
<script type="text/javascript">
	
	
	$(function(){
	
	var data = "";
	var value = "";
	
	$("#to_complaint").keyup(function(){
		
		value = $("#to_complaint").val();
		//alert(value);
		data = $.ajax({
			type : "GET",
			url : "control.php?control=auto_complete",
			data : "control2=" + value,
			async: false	//for responseText
		}).responseText.split("--|--");
		$("#to_complaint").autocomplete(data);
	});
	
	//var data = "Merhaba ben ibrahim merkez".split(" ");
	
	
	<?php
	if(isset($secili_link)){
	?>
		$("#ic-sol > #kategoriler > ul > li:eq(<?php echo $secili_link; ?>)").attr("class","secili");
	<?php	
	}
	?>
	
	$(".main_categories > a.categories_del, .main_categories > a.categories_edit").hover(function(){ $(this).css("text-decoration","underline") }, function(){ $(this).css("text-decoration","none"); });
	
	$("a.del_link").click(function(){
		var conf = confirm("Seçilen şikayeti silmek istediğinizden emin misiniz?");	
		if(conf == true)
			return true;
		else
			return false;
	});
	$("a.giveup_watch").click(function(){
		var conf = confirm("Seçilen şikayeti izlemekten vazgeçmek istediğinizden emin misiniz?");	
		if(conf == true)
			return true;
		else
			return false;
	});
	
	$('input[name="category_type"]').change(function(){
		var selected_var = $(this).attr("value");
		$(".category_type_config_option > select").removeAttr("disabled");
		$(".category_type_config_option > select:not(#category_type_config_option_"+selected_var+" > select)").attr("disabled","disabled");
		$(".category_type_config_option").css("display","none");
		setTimeout(function(){
			$("#category_type_config_option_"+selected_var).css("display","block");
			$("#category_type_config_option_"+selected_var).attr("disabled","");
		},50);			
	});
	
	<?php 
		if(isset($_GET["edit"])){
			$edit_id = (int)$hh->escape($_GET["edit"]);
			$edit_item = $hh->fetch_array($hh->db_get("*","categories","id=$edit_id"));
			?>
			$(".category_type_config_option > select").removeAttr("disabled");
			$(".category_type_config_option > select:not(#category_type_config_option_<?php echo $edit_item["type"]; ?>"+" > select)").attr("disabled","disabled");
			$(".category_type_config_option").css("display","none");
			$("#category_type_config_option_<?php echo $edit_item["type"]; ?>").css("display","block");
			$("#category_type_config_option_<?php echo $edit_item["type"]; ?>").attr("disabled","");
			<?php
		}
	?>
	
	$(".main_categories, .sub_categories, .sub_sub_categories").hover(function(){ $(this).addClass("categories_hover"); },function(){ $(this).removeClass("categories_hover"); });
	
	$("a.categories_del").click(function(){
		var del_complaints = $('input[name="categories_del_complaints"]:checked').val();
		var del_sub_categories = $('input[name="categories_del_sub_categories"]:checked').val();
		var dcomp;
		var dcat;
		if(del_complaints == "1")
			dcomp = "Sil";
		if(del_complaints == "0")
			dcomp = "Varsayılan alt-alt kategoriye taşı";
		if(del_sub_categories == "1")
			dcat = "Sil";
		if(del_sub_categories == "0")
			dcat = "Varsayılan kategoriye taşı";
		var conf = confirm("Seçilen kategoriyi şu ayarlarla beraber silmek istediğinizden emin misiniz? \n \n Altındaki şikayetleri : "+dcomp+"\n Altındaki kategorileri : "+dcat);	
		if(conf == true){
			url = $(this).attr("href");
			$(this).attr("href", url+"&del_complaints="+parseInt(del_complaints)+"&del_sub_categories="+parseInt(del_sub_categories));
			
		}
		else
			return false;
	});
	
	<?php
	if($panel == "users"){
	?>
		
		
		$( "#dialog" ).dialog( "destroy" );

		$(".users_info").click(function(){
			var user_info = new Array();
			user_info = $(this).attr("alt").split("--|--");
			$("#dialog-message > #username").html("Kullanıcı Adı : "+user_info[0]);
			$("#dialog-message > #name").html("İsim : "+user_info[1]);
			$("#dialog-message > #authority").html("Yetki : "+user_info[2]);
			$("#dialog-message > #email").html("E-posta : "+user_info[3]);
			$("#dialog-message > #user_point").html("Puan : "+user_info[4]);
			$("#dialog-message > #reg_date").html("Kayıt Tarihi : "+user_info[5]);
			$("#dialog-message > #last_access_date").html("Son Erişim Tarihi : "+user_info[6]);
			$("#dialog-message > #block").html("Durum : "+user_info[7]);
			$( "#dialog-message" ).dialog({
			modal: true,
			buttons: [
				{
					text: "Tamam",
					click: function() { $(this).dialog("close"); }
				}
			]
		});
		});
		
	<?php	
	}
	elseif($panel == "all_complaints"){
	?>	
		$( "#dialog" ).dialog( "destroy" );

		$(".users_info").live("click",function(){
			var user_info = new Array();
			user_info = $(this).attr("alt").split("--|--");
			$("#dialog-message > #username").html("Başlık : "+user_info[0]);
			$("#dialog-message > #name").html("Kategori : "+user_info[1]);
			$("#dialog-message > #authority").html("Yazar : "+user_info[2]);
			$("#dialog-message > #email").html("Şikayet Mercii : "+user_info[3]);
			$("#dialog-message > #user_point").html("Durum : "+user_info[4]);
			$("#dialog-message > #reg_date").html("Kayıt Tarihi : "+user_info[5]);
			$("#dialog-message > #last_access_date").html("Puan : "+user_info[6]);
			$("#dialog-message > #block").html("Oylama Sayısı : "+user_info[7]);
			$("#dialog-message > #1").html("Yorum Sayısı : "+user_info[8]);
			$("#dialog-message > #2").html("Okunma Sayısı : "+user_info[9]);
			$( "#dialog-message" ).dialog({
			modal: true,
			buttons: [
				{
					text: "Tamam",
					click: function() { $(this).dialog("close"); }
				}
			]
			});
		});
		
		
	<?php	
	}
	?>
	
		$("#filter_form").submit(function(){
			window.location = "index.php?page=panel&panel=all_complaints&block="+$('.block:checked').val()+"&title="+$(".title").val()+"&category="+$(".category").val()+"&author="+$(".author").val()+"&to_complaint="+$(".to_complaint").val()+"&from_to="+$(".from_to:checked").val();
			
			return false;	
		});
	
	});
	
	<?php
	if($panel == "users"){
	?>	
		$("a.users_del").live("click",function(){
			if($(this).attr("title") == "Aktif hale getir")
				conf_message = "aktif hale getirmek";
			else if($(this).attr("title") == "Engelle")
				conf_message = "engellemek";
			var conf = confirm("Bu kullanıcıyı "+conf_message+" istediğinizden emin misiniz?");	
			if(conf == true)
				return true;
			else
				return false;
	});
	<?php
	}
	if($panel == "all_complaints"){
	?>
		$("a.users_del").live("click",function(){
			if($(this).attr("title") == "Aktif hale getir")
				conf_message = "aktif hale getirmek";
			else if($(this).attr("title") == "Engelle")
				conf_message = "engellemek";
			else if($(this).attr("title") == "Onayla ve aktif hale getir")
				conf_message = "onaylamak ve aktif hale getirmek";
			var conf = confirm("Bu şikayeti "+conf_message+" istediğinizden emin misiniz?");	
			return conf;
		});
		
		
		$("a.complaint_del").live("click",function(){
			var conf_message_d = confirm("Bu şikayeti silmek istediğinizden emin misiniz?");	
			if(conf_message_d == true)
				return true;
			else
				return false;
		});
	<?php
	}
	?>

</script>
</head>

<body>
<!-- jQuery Dialog Start -->
<div id="dialog-message" title="<?php if($panel == "users") echo "Kullanıcı Bilgileri"; elseif($panel == "all_complaints") echo "Şikayet Bilgileri"; ?>">
	<p id="username"></p>
	<p id="name"></p>
    <p id="authority"></p>
    <p id="email"></p>
    <p id="user_point"></p>
    <p id="reg_date"></p>
    <p id="last_access_date"></p>
    <p id="block"></p>
    <?php
	if($panel == "all_complaints"){
	?>
    <p id="1"></p>
    <p id="2"></p>
    <?php
	}
	?>
</div>
<!-- jQuery Dialog End -->

<div id="bulut">

	<div id="site" >
    	<?php include("banner.php"); ?>
        
        <div id="orta">
        	
            <div id="ic-sol">
                
                <!-- Sol taraftaki menü başlangıç -->
                
                <div id="kategoriler">
                	
                    <div id="baslik">
                    	<div class="kose"></div>
                        <div class="yazi">İşlemler</div>
                    </div>
                    
                	<ul>
                    	<li><a href="index.php?page=panel&panel=new_complaint" style="text-decoration:underline;">Yeni Şikayet Yaz</a></li>
                        <li><a href="index.php?page=panel&panel=my_complaints">Şikayetlerim</a><span>(<?php echo $num_complaints; ?>)</span></li>
                        <li><a href="index.php?page=panel&panel=watchlist">İzleme Listem</a><span>(<?php echo $num_watchlist; ?>)</span></li>
                        <li><a href="index.php?page=panel&panel=settings">Kullanıcı Ayarları</a></li>
                        <br />
                        <?php
                        if($hh->can_access(1)){		//Only admins
						?>
                        <li><a href="index.php?page=panel&panel=configuration">Site Ayarları</a></li>
                        <li><a href="index.php?page=panel&panel=categories">Kategoriler</a></li>
                        <li><a href="index.php?page=panel&panel=users">Kullanıcılar</a></li>
                        <li><a href="index.php?page=panel&panel=all_complaints&block=2&title=&category=all&author=all&to_complaint=&from_to=from_to_new">Tüm Şikayetler</a></li>
                        <li><a href="index.php?page=panel&panel=all_comments">Tüm Yorumlar</a></li>
                        <li><a href="index.php?page=panel&panel=articles">Yazılar</a></li>
                        <?php
						}
						?>
                    </ul>
                </div>
                <!-- Sol taraftaki menü bitiş -->
                
                <!-- Orta kısım mesajlar başlangıç -->
                <div id="icerik">
                
                	<div class="baslik">
                		<h3>
                      	<?php
					  	switch($panel){
							case "new_complaint" : echo "Yeni Şikayet"; break;
							case "my_complaints" : echo "Şikayetlerim"; break;
							case "watchlist" : echo "İzleme Listesi"; break;
							case "settings" : echo "Ayarlar"; break;
							case "categories" : echo "Kategoriler"; break;
						}					  
						?>
                    	</h3>
                	</div>
                    <div class="mesajlar">
                    
                    <?php
						switch($panel){
							case "new_complaint" :
								if(isset($_GET["edit"])){
									$edit_id = (int)$hh->escape($_GET["edit"]);
									$edit_item = $hh->fetch_array($hh->db_get("*","complaints","id=$edit_id"));
										
									if($_SESSION["current_user"]["id"] != $edit_item["author"]){
										if($hh->can_access(1) == false)
											$edit_id = false;
									}
								}
								else
									$edit_id = false;
								//YENİ ŞİKAYET
								?>
                                <!-- mesaj başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                                                                        
                                            <br />
                                            <form action="control.php?control=<?php if($edit_id != false) echo "update"; else echo "add"; ?>_complaint" method="post">
                                            	<div class="comp_formsatir" style="float:none;">
                                                	Başlık :&nbsp;<br />
                                                    <input class="comp_input" type="text" name="title" <?php if($edit_id != false){ echo "value='".$edit_item["title"]."'"; } ?> />
                                                </div>
                                                <div class="comp_formsatir" style="float:none;">
                                                	Şikayet Edilen :<br />
                                                    <input id="to_complaint" class="comp_input" type="text" name="to_complaint" <?php if($edit_id != false) echo "value='".$edit_item["to_complaint"]."'"; ?> />
                                                    <?php
													$veri=@$_GET["veri"];
													if($veri)
													{
													$sql = "select to_complaint from complaints where to_complaint like '$veri%' limit 5 ORDER BY id DESC";
													
													$sqlsonuc = mysql_query($sql);
														if(mysql_num_rows($sqlsonuc))
														{
																while($row = mysql_fetch_array($sqlsonuc))
																{
																	echo "<input style='cursor: pointer;' onclick='tamamla(this.value)' type='text' value='".$row["to_complaint"]."' />";
																}
														}
													}
													?>
                                                </div>
                                                <div class="comp_formsatir" style="float:none;">
                                                	Kategori :&nbsp;<br />
                                                    <select class="comp_selectbox" name="category">
                                                            <?php
															$sql_main_cat = $hh->get_categ(1);
															while($main_cat = $hh->fetch_array($sql_main_cat)){
																$sql_sub_cat = $hh->get_categ(NULL, (int)$main_cat['id']);
																?>
                                                                <optgroup label="<?php echo $main_cat["category_name"]; ?>">
                                                                    <?php
																	while($sub_cat = $hh->fetch_array($sql_sub_cat)){
																		$sql_sub_sub_cat = $hh->get_categ(NULL, (int)$sub_cat['id']);
																	?>
                                                                    	<optgroup label="<?php echo $sub_cat["category_name"]; ?>">
                                                                        <?php
																		while($sub_sub_cat = $hh->fetch_array($sql_sub_sub_cat)){
																		?>
                                                                    	<option <?php if($edit_id != false && $edit_item["category"] == $sub_sub_cat["id"]) echo "selected='selected'"; ?> value="<?php echo $sub_sub_cat["id"]; ?>"><?php echo $sub_sub_cat["category_name"]; ?></option>
                                                                        <?php
																		}
																		?>
                                                                        </optgroup>
                                                                    <?php
																	}
																	?>
																</optgroup>
																<?php
															}
															?>
                                                            </select>
                                                </div>
                                                <div class="comp_formsatir" style="float:none;">
                                                	Mesaj :&nbsp;<br />
                                                    <textarea class="comp_textarea" name="content"><?php if($edit_id != false) echo $edit_item["content"]; ?></textarea>
                                                </div>
                                                <div style="height:10px;display:block;clear:both;"></div>
                                                <div class="setting_line" style="float:none;">
                                                <?php if($edit_id != false) echo "<input name='edit_id' type='hidden' value='".$edit_id."' />"; ?>
                                                	<center><input type="submit" class="save_settings" value="" /></center>
                                                </div>
                                            <div class="clear"></div>    
                                            </form>
                                            <br /><br /><br /><br /><br /><br />
                                            
                                            </div>
                                            
                                            <div class="kma duz"></div>
                                        
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- mesaj bitiş -->
                                <?php
							break;
							
							case "my_complaints" :
								if($num_complaints == 0){
								?>
                                <div class="no_object">Şu ana kadar şikayet yazmamışsınız</div>
                                <?php
								}
								else{
									$page_num = $hh->escape(@$_GET["page_num"]);
									if($page_num == "")
										$page_num = 1;
									else
										$page_num = (int)$page_num;
									$per_page = 5;
									$page_number = (($num_complaints - ($num_complaints%$per_page)) / $per_page) + 1;
									$sql_my_complaints = $hh->db_get("*","complaints","author=".(int)$_SESSION['current_user']['id'], "ORDER BY add_date DESC LIMIT ".(($page_num-1)*$per_page).", $per_page");
									while($my_complaints = $hh->fetch_array($sql_my_complaints)){
										?>
                                        <!-- konu başlangıç -->
                                        <div class="mesaj">
                                            
                                            <div class="kutu">
                                                <div class="kutumesaj">
                                                    <div class="kmu"></div>
                                                    
                                                    <div class="kmo">
                                                    
                                                    <div class="kutubaslik"><?php echo $my_complaints["title"]; ?></div>
                                                    <div style="float:left;">
                                                    <?php
														$text = explode(".", $my_complaints["content"]);
														if(count($text) <= 5){
															$result_text = $my_complaints["content"];
														}
														else{
															for($x = 0; $x < 5; $x++){
																$result_text .= $txt[$x];
															}	
														}
														echo $hh->reverse_date($my_complaints["add_date"])."<br />";
														echo $result_text;
													?>
                                                    </div>
                                                    <div style="float:right;">
                                                    	<a href="control.php?control=del_complaint&control2=<?php echo $my_complaints["id"]; ?>" class="del_link">Şikayeti Sil</a><br />
                                                        <a href="#" class="update_link">Düzenle</a>
                                                    </div>
                                                    <br /><br />
                                                    <a href="#">Tümünü görüntüle...</a></div>
                                                    
                                                    <div class="kma duz"></div>
                                                                                    
                                                </div>
                                            </div>
                                            
                                        </div>
                                        <!-- konu bitiş -->
                                        <?php
									}		//while bitiş
									?>
										<!-- sayfalama başlangıç -->
                                        <div id="sayfalama">
                                            
                                        <?php
											for($x = 1; $x <= $page_number; $x++){
											?>
                                            	<div class="sayfa"><a <?php if($x == $page_num){ ?>class="secili"<?php } ?> href="index.php?page=panel&panel=my_complaints&page_num=<?php echo $x; ?>"><?php echo $x; ?></a></div>
                                            <?php
											}
										?>
                                        <div class="clear"></div>
                                        </div>
                                        <!-- sayfalama bitiş -->
									<?php
								}
							break;	//my_complaints bitiş
							
							case "watchlist" :
								if($num_watchlist == 0){
								?>
                                <div class="no_object">Hiçbir şikayeti takip etmiyorsunuz</div>
                                <?php
								}
								else{
									$page_num = $hh->escape(@$_GET["page_num"]);
									if($page_num == "")
										$page_num = 1;
									else
										$page_num = (int)$page_num;
									$per_page = 10;
									$page_number = (($num_watchlist - ($num_watchlist%$per_page)) / $per_page) + 1;
									$sql_watchlist = $hh->db_get("*","complaints","watchlist", "LIKE '%-".$_SESSION['current_user']['id']."-%' ORDER BY add_date DESC LIMIT ".(($page_num-1)*$per_page).", $per_page");
									while($watchlist = $hh->fetch_array($sql_watchlist)){
										?>
                                        <!-- konu başlangıç -->
                                        <div class="mesaj" style="margin-bottom:0px;">
                                            
                                            <div class="kutu">
                                                <div class="kutumesaj">
                                                    <div class="kmu"></div>
                                                    
                                                    <div class="kmo">
                                                    
                                                    <div class="kutubaslik"></div>
                                                    <div style="float:left;">
                                                    <?php
														echo $watchlist["title"];
													?>
                                                    </div>
                                                    <div style="float:right;">
                                                    	<a href="control.php?control=giveup_watch&control2=<?php echo $watchlist["id"]; ?>" class="giveup_watch">İzlemekten vazgeç</a><br />
                                                    </div>
                                                    <br />
                                                    <a href="#">Şikayeti görüntüle...</a>
                                                    </div>
                                                    
                                                    <div class="kma duz"></div>
                                                                                    
                                                </div>
                                            </div>
                                            
                                        </div>
                                        <!-- konu bitiş -->
                                        <?php
									}		//while bitiş
									?>
										<!-- sayfalama başlangıç -->
                                        <div id="sayfalama">
                                            
                                        <?php
											for($x = 1; $x <= $page_number; $x++){
											?>
                                            	<div class="sayfa"><a <?php if($x == $page_num){ ?>class="secili"<?php } ?> href="index.php?page=panel&panel=watchlist&page_num=<?php echo $x; ?>"><?php echo $x; ?></a></div>
                                            <?php
											}
										?>
                                        <div class="clear"></div>
                                        </div>
                                        <!-- sayfalama bitiş -->
									<?php
								}
							break;	//watchlist bitiş
							
							case "settings" :
								?>
                                <!-- konu başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                            
                                            <div class="kutubaslik"></div>
                                           		<form action="control.php?control=settings" method="post">
                                                <br />
                                                	<div class="left-one">
                                                    	<div class="setting_line">Ad : </div><br />
                                                        <div class="setting_line">E-posta : </div><br /><br /><br />
                                                        <font style="text-decoration:underline;">Değiştirmek istiyorsanız</font><br />
                                                        <div class="setting_line">Yeni Parola : </div><br />
                                                        <div class="setting_line">Yeni Parola(Tekrar) : </div><br /><br /><br />
                                                        <font style="text-decoration:underline;">Kaydetmek için</font><br />
                                                        <div class="setting_line"><font style="color:#C00;">Parola*</font> : </div>
                                                    </div>
                                                    <div class="right-one">
                                                    	<div class="setting_line"><input type="text" name="name" value="<?php echo $_SESSION["current_user"]["name"]; ?>" /></div><br />
                                                        <div class="setting_line"><input type="text" name="email" value="<?php echo $_SESSION["current_user"]["email"]; ?>" /></div><br /><br /><br /><br />
                                                        <div class="setting_line"><input type="password" name="new_pass" /></div><br />
                                                        <div class="setting_line"><input type="password" name="new_pass_t" /></div><br /><br /><br /><br />
                                                        <div class="setting_line"><input type="password" name="pass" /></div><br /><br />
                                                        <input type="submit" class="save_settings" value="" />
                                                    </div>
                                                </form>
                                            <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
                                            </div>
                                            
                                            <div class="kma duz"></div>
                                                                            
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- konu bitiş -->
                                <?php
							break;	//settings bitiş
							
							case "categories" :
							if($hh->can_access(1)){
								if(isset($_GET["edit"])){
									$edit_id = (int)$hh->escape($_GET["edit"]);
									$edit_item = $hh->fetch_array($hh->db_get("*","categories","id=$edit_id"));
									
								}
								else
									$edit_id = false;
							?>
                            	<!-- konu başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                            
                                            <div class="kutubaslik"><?php if($edit_id) echo "Kategori Düzenle"; else echo "Yeni Kategori Ekle"; ?></div>
                                           		<form id="add_category_form" action="control.php?control=<?php if($edit_id) echo "update"; else echo "add"; ?>_category" method="post">
                                                <br />
                                                	<?php if($edit_id == false){ ?>
                                                	Kategori Türü :
                                                	<input type="radio" name="category_type" id="cat_type_1" value="1" /><label for="cat_type_1">Üst</label>
                                                    <input type="radio" name="category_type" id="cat_type_2" value="2" /><label for="cat_type_2">Alt</label>
                                                    <input type="radio" name="category_type" id="cat_type_3" value="3" /><label for="cat_type_3">Alt-Alt</label><br /><br />
                                                    <?php } ?>
                                                    <div id="category_type_config">
                                                    	<div class="category_type_config_option" id="category_type_config_option_3">
                                                        Alt Kategori :
                                                        	<select name="category_parent">
                                                            <?php
															$sql_main_cat = $hh->db_get("*","categories","type=1");
															while($main_cat = $hh->fetch_array($sql_main_cat)){
																?>
                                                                <optgroup label="<?php echo $main_cat["category_name"]; ?>">
                                                            		<?php
																	$sql_sub_cat = $hh->db_get("*","categories","type=2 AND parent=".(int)$main_cat['id']);
																	?>
                                                                    <?php
																	while($sub_cat = $hh->fetch_array($sql_sub_cat)){
																	?>
                                                                    	<option <?php if($edit_id){ if($edit_item["parent"] == $sub_cat["id"]) echo "selected='selected'"; } ?> value="<?php echo $sub_cat["id"]; ?>"><?php echo $sub_cat["category_name"]; ?></option>
                                                                    <?php
																	}
																	?>
																</optgroup>
																<?php
															}
															?>
                                                            </select>
                                                        </div>
                                                        <div class="category_type_config_option" id="category_type_config_option_2">
														Üst Kategori :
                                                        	<select name="category_parent">
                                                            <?php
															$sql_main_cat = $hh->db_get("*","categories","type=1");
															while($main_cat = $hh->fetch_array($sql_main_cat)){
																?>
                                                                <option <?php if($edit_id){ if($edit_item["parent"] == $main_cat["id"]) echo "selected='selected'"; } ?> value="<?php echo $main_cat["id"]; ?>"><?php echo $main_cat["category_name"]; ?></option>
																<?php
															}
															?>
                                                            </select>
                                                        </div>
                                                    </div><br />
                                                    Kategori Adı : 
													<input type="text" name="category_name" <?php if($edit_id) echo "value='".$edit_item['category_name']."'"; ?> /><!-- MAX 30 char -->
                                                    <?php if($edit_id){ ?><input type="hidden" name="id" value="<?php echo $edit_id; ?>" /><?php } ?>
                                                    <br /><br />
													<div style="text-align:center;"><input type="submit" class="save_settings" value="" /></div>
                                                </form>
                                            <br />
                                            </div>
                                            
                                            <div class="kma duz"></div>
                                                                            
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- konu bitiş -->
                                <!-- konu başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                            
                                            <div class="kutubaslik">Kategoriler</div><br />
                                            <form>
                                            <font style="text-decoration:underline;">Üst, alt ve alt-alt kategori silerken : </font><br />
                                            Altındaki şikayetleri : <input type="radio" name="categories_del_complaints" id="del_complaints_1" value="1" /><label for="del_complaints_1">Sil</label><input style="margin-left:10px;" type="radio" name="categories_del_complaints" id="del_complaints_2" checked="checked" value="0" /><label for="del_complaints_2">Varsayılan alt-alt kategoriye taşı</label><br />
                                            <font style="text-decoration:underline;">Üst ve alt kategori silerken : </font><br />
                                            Altındaki kategorileri : <input type="radio" name="categories_del_sub_categories" id="del_sub_categories_1" value="1" /><label for="del_sub_categories_1">Sil</label><input style="margin-left:10px;" type="radio" name="categories_del_sub_categories" id="del_sub_categories_2" checked="checked" value="0" /><label for="del_sub_categories_2">Varsayılan kategoriye taşı</label><br />
                                            </form>
                                            <br /><br />
                                           	<?php
											$sql_main_categories = $hh->db_get("*","categories","type=1");
											while($main_categories = $hh->fetch_array($sql_main_categories)){
											?>
                                            	<div class="main_categories"><?php echo $main_categories["category_name"]." (Üst) "; ?><a href="control.php?control=del_category&control2=<?php echo $main_categories["id"]; ?>" style="color:#c00;" class="categories_del">Kaldır</a><a href="index.php?page=panel&panel=categories&edit=<?php echo $main_categories["id"]; ?>" class="categories_edit">Düzenle</a></div>
                                            <?php
												$sql_sub_categories = $hh->db_get("*","categories","type=2 AND parent=".(int)$main_categories["id"]);
												while($sub_categories = $hh->fetch_array($sql_sub_categories)){
												?>
                                                	<div class="sub_categories"> > <?php echo $sub_categories["category_name"]." (Alt) "; ?><a href="control.php?control=del_category&control2=<?php echo $sub_categories["id"]; ?>" style="color:#c00;" class="categories_del">Kaldır</a><a href="index.php?page=panel&panel=categories&edit=<?php echo $sub_categories["id"]; ?>" class="categories_edit">Düzenle</a></div>
                                                <?php
													$sql_sub_sub_categories = $hh->db_get("*","categories","type=3 AND parent=".(int)$sub_categories["id"]);
													while($sub_sub_categories = $hh->fetch_array($sql_sub_sub_categories)){
													?>
                                                    	<div class="sub_sub_categories"> >> <?php echo $sub_sub_categories["category_name"]." (Alt-alt) "; ?><a href="control.php?control=del_category&control2=<?php echo $sub_sub_categories["id"]; ?>" style="color:#c00;" class="categories_del">Kaldır</a><a href="index.php?page=panel&panel=categories&edit=<?php echo $sub_sub_categories["id"]; ?>" class="categories_edit">Düzenle</a></div>
                                                    
                                                    <?php
													}
												}
											}
											?>
                                            <div class="clear"></div><br />
                                            </div>
                                            <div class="kma duz"></div>
                                                                            
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- konu bitiş -->
                            <?php
							}
							break;
							
							case "articles" :
								if($num_article == 0){
								?>
                                <div class="no_object">Sistemde kayıtlı yazı yok</div>
                                <?php
								}
								else{
									$page_num = $hh->escape(@$_GET["page_num"]);
									if($page_num == "")
										$page_num = 1;
									else
										$page_num = (int)$page_num;
									$per_page = 5;
									$page_number = (($num_article - ($num_article%$per_page)) / $per_page) + 1;
									$sql_article = $hh->db_get("*","articles", 1, "ORDER BY add_date DESC LIMIT ".(($page_num-1)*$per_page).", $per_page");
									while($articles = $hh->fetch_array($sql_article)){
										?>
                                        <!-- konu başlangıç -->
                                        <div class="mesaj">
                                            
                                            <div class="kutu">
                                                <div class="kutumesaj">
                                                    <div class="kmu"></div>
                                                    
                                                    <div class="kmo">
                                                    
                                                    <div class="kutubaslik"><?php echo $articles["title"]; ?></div>
                                                    <div class="my_complaint_left">
                                                    <?php
														$text = explode(" ", $articles["content"]);
														if(count($text) <= 10){
															$result_text = $articles["content"];
														}
														else{
															for($x = 0; $x < 10; $x++){
																$result_text .= $text[$x]." ";
															}	
														}
														echo $hh->reverse_date($articles["add_date"])."<br />";
														echo $result_text."...";
														$result_text = "";
													?>
                                                    <br /><a href="index.php?page=articles&id=<?php echo $articles["id"];?>">Tümünü görüntüle...</a>
                                                    </div>
                                                    <div class="my_complaint_right">
                                                    	<a href="control.php?control=del_article&control2=<?php echo $articles["id"]; ?>" class="del_link">Yazıyı Sil</a><br />
                                                        <a href="#" class="update_link">Düzenle</a>
                                                    </div>
                                                    <div class="clear"></div>
                                                    </div>
                                                    
                                                    <div class="kma duz"></div>
                                                                                    
                                                </div>
                                            </div>
                                            
                                        </div>
                                        <!-- konu bitiş -->
                                        <?php
									}		//while bitiş
									?>
										<!-- sayfalama başlangıç -->
                                        <div id="sayfalama">
                                            
                                        <?php
											for($x = 1; $x < $page_number; $x++){
											?>
                                            	<div class="sayfa"><a <?php if($x == $page_num){ ?>class="secili"<?php } ?> href="index.php?page=panel&panel=articles&page_num=<?php echo $x; ?>"><?php echo $x; ?></a></div>
                                            <?php
											}
										?>
                                        <div class="clear"></div>
                                        </div>
                                        <!-- sayfalama bitiş -->
									<?php
								}
							break;	//articles bitiş
							
							case "users" :
							if($hh->can_access(1)){
							if(isset($_GET["edit"])){
								$edit_id = (int)$hh->escape($_GET["edit"]);
								$edit_item = $hh->fetch_array($hh->db_get("*","users","id=$edit_id"));
							}
							else
								$edit_id = false;
							?>
                            	<!-- konu başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                            
                                            <div class="kutubaslik">Kullanıcı <?php if($edit_id) echo "Düzenle"; else echo "Ekle"; ?></div>
                                            <form action="control.php?control=<?php if($edit_id) echo "update_user"; else echo "add_user"; ?>" method="post">
                                            	<br />
                                                <div style="text-align:center">
                                            	Yetki : 
                                                <input <?php if($edit_id){ if($edit_item["authority"] == 1) echo "checked='checked'"; } ?> type="radio" name="authority" value="1" id="auth_1" /><label for="auth_1">Admin</label>
                                                <input <?php if($edit_id){ if($edit_item["authority"] == 2) echo "checked='checked'"; } ?> type="radio" name="authority" value="2" id="auth_2" /><label for="auth_2">Editör</label>
                                                <input <?php if($edit_id){ if($edit_item["authority"] == 3) echo "checked='checked'"; } ?> type="radio" name="authority" value="3" id="auth_3" /><label for="auth_3">Üye</label>
                                                </div>
                                                <br />
                                                <div class="left-one" style="margin-left:50px;">
                                                	<div class="setting_line">Kullanıcı Adı : </div><br />
                                                    <div class="setting_line">İsim : </div><br />
                                                    <div class="setting_line">Parola : </div><br />
                                                </div>
                                                <div class="right-one">
                                                	<div class="settting_line"><input type="text" name="username" <?php if($edit_id){ ?> value="<?php echo $edit_item["username"]; ?>" <?php } ?> /></div>
                                                    <div class="setting_line"><input type="text" name="name" <?php if($edit_id){ ?> value="<?php echo $edit_item["name"]; ?>" <?php } ?> /></div><br />
                                                    <div class="setting_line"><input type="password" name="password" <?php if($edit_id) echo "value='No_Pas*swor|d'"; ?> /></div><br />
                                                    <?php if($edit_id){ ?><input type="hidden" name="id" value="<?php echo $edit_id; ?>" /><?php } ?>
													<input type="submit" class="save_settings" value="" />
                                                </div>
                                            </form>
                                            <div class="clear"></div>
                                            </div>
                                            
                                            <div class="kma duz"></div>
                                                                        
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- konu bitiş -->
                                <!-- konu başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                            
                                            <div class="kutubaslik">Kullanıcılar</div><br />
                                            <?php
											if(isset($_GET["user_page"]))
												$user_page = $hh->escape($_GET["user_page"]);
											else
												$user_page = 1;
											
											$sql_user = $hh->db_get("id","users");
											$user_count = $hh->num_rows($sql_user);
											if($user_count > 0)
												$user_count = $user_count-1;
											else
												$user_count = 0;
												
											$user_per_page = 25;
											$page_count = (($user_count - ($user_count%$user_per_page)) / $user_per_page) + 1;
												
											$sql_users = $hh->db_get("*","users","id!=".(int)$_SESSION["current_user"]["id"], "ORDER BY reg_date DESC LIMIT ".(($user_page-1)*$user_per_page).", $user_per_page");
											
											while($users = $hh->fetch_array($sql_users)){
												if($users["block"] == 0) $block = "Aktif"; else $block = "Engelli";
												if($users["authority"] == 1) $auth = "Admin"; elseif($users["authority"] == 2) $auth = "Editor"; elseif($users["authority"] == 3) $auth = "Kullanıcı";
											if($users["block"] == 0){ $font1 = ""; $font2 = "";}
											else{ $font1 = "<font color='red'>"; $font2 = "</font>"; }
											?>
                                            <div class="main_categories"><?php echo $users["username"]." (".$font1.$block.$font2.") - $auth "; ?><a href="control.php?control=block_user&control2=<?php echo $users["id"]; ?>" style="color:#c00;" class="users_del" title="<?php if($users["block"]==0) echo "Engelle"; else echo "Aktif hale getir"; ?>"><img src="images/design/<?php if($users["block"]==0) echo "block-logo"; else echo "activate-logo"; ?>.png" alt="block" /></a><a href="index.php?page=panel&panel=users&edit=<?php echo $users["id"]; ?>" class="users_edit" title="Düzenle"><img src="images/design/edit-button.png" alt="edit" /></a><img class="users_info" src="images/design/user-logo.png" title="Kullanıcı Bilgileri" alt="<?php echo $users["username"]."--|--".$users["name"]."--|--".$auth."--|--".$users["email"]."--|--".$users["user_point"]."--|--".$users["reg_date"]."--|--".$users["last_access_date"]."--|--".$block; ?>" /></div>
                                            <?php
											}
											?>
                                            <div class="clear"></div>
                                            </div>
                                            
                                            <div class="kma duz"></div>
                                                                        
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- konu bitiş -->
                                <!-- sayfalama başlangıç -->
                                <div id="sayfalama">
                                    
                                <?php
                                    for($x = 1; $x <= $page_count; $x++){
                                    ?>
                                        <div class="sayfa"><a <?php if($x == $user_page){ ?>class="secili"<?php } ?> href="index.php?page=panel&panel=users&user_page=<?php echo $x; ?>"><?php echo $x; ?></a></div>
                                    <?php
                                    }
                                ?>
                                <div class="clear"></div>
                                </div>
                                <!-- sayfalama bitiş -->
                            <?php
							}
							break;
							
							case "configuration" :
							if($hh->can_access(1)){
								$check_complaints = $hh->fetch_array($hh->db_get("value","settings","id=4"));
								$check_comments = $hh->fetch_array($hh->db_get("value","settings","id=3"));
								$check_articles = $hh->fetch_array($hh->db_get("value","settings","id=7"));
								$check_complaints = $check_complaints["value"];
								$check_comments = $check_comments["value"];
								$check_articles = $check_articles["value"];
							?>
                            <!-- konu başlangıç -->
                            <div class="mesaj">
                                
                                <div class="kutu">
                                    <div class="kutumesaj">
                                        <div class="kmu"></div>
                                        
                                        <div class="kmo">
                                        
                                        <div class="kutubaslik">Site Ayarları</div><br />
                                        <form action="control.php?control=configuration" method="post">
                                        	Şikayetleri : 
                                            <input <?php if($check_complaints == 1) echo "checked='checked'"; ?> type="radio" name="check_complaints" value="1" id="check_complaints_1" /><label for="check_complaints_1">Kontrol Et</label>
                                            <input <?php if($check_complaints == 0) echo "checked='checked'"; ?> type="radio" name="check_complaints" value="0" id="check_complaints_0" /><label for="check_complaints_0">Kontrol Etme</label>
                                            <br /><br />
                                            Yorumları : 
                                            <input <?php if($check_comments == 1) echo "checked='checked'"; ?> type="radio" name="check_comments" value="1" id="check_commments_1" /><label for="check_commments_1">Kontrol Et</label>
                                            <input <?php if($check_comments == 0) echo "checked='checked'"; ?> type="radio" name="check_comments" value="0" id="check_commments_0" /><label for="check_commments_0">Kontrol Etme</label>
                                            <br /><br />
                                            Yazıları : 
                                            <input <?php if($check_articles == 1) echo "checked='checked'"; ?> type="radio" name="check_articles" value="1" id="check_articles_1" /><label for="check_articles_1">Kontrol Et</label>
                                            <input <?php if($check_articles == 0) echo "checked='checked'"; ?> type="radio" name="check_articles" value="0" id="check_articles_0" /><label for="check_articles_0">Kontrol Etme</label><br /><br />
                                            <input type="submit" class="save_settings" value="" />
                                        </form>
                                        </div>
                                        <div class="kma duz"></div>
                                                                        
                                    </div>
                                </div>
                                
                            </div>
                            <!-- konu bitiş -->
                            <?php
							}
							break;
							
							case "all_complaints" :
							if($hh->can_access(1)){
							?>
                                <!-- konu başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                            
                                            <div class="kutubaslik">Filtre</div><br />
                                            <form id="filter_form" action="#" method="post">
                                            <input <?php if($_GET["block"] == "all") echo "checked='checked'"; ?> type="radio" value="all" name="block" id="block_all" class="block" /><label for="block_all"><b>Tümü</b></label>
                                            <input <?php if((int)$_GET["block"] == 2) echo "checked='checked'"; ?> type="radio" value="2" name="block" id="block_2" class="block" /><label for="block_2">Beklemedekiler</label>
                                            <input <?php if((int)$_GET["block"] == 1) echo "checked='checked'"; ?> type="radio" value="1" name="block" id="block_1" class="block" /><label for="block_1">Engelliler</label>
                                            <input <?php if((int)$_GET["block"] == 0 && $_GET["block"] != "all") echo "checked='checked'"; ?> type="radio" value="0" name="block" id="block_0" class="block" /><label for="block_0">Yayınlanmışlar</label>
                                            <br /><br />
                                            Başlık :
                                            <input type="text" name="title" class="title" <?php if($_GET["title"] != "") echo "value='".$_GET["title"]."'"; ?>  /><br /><br />
                                            Kategori : 
                                            <select name="category" class="category">
                                            	<option <?php if($_GET["category"] == "all") echo "selected='selected'"; ?>  value="all">Tümü</option>
                                                <?php
												$sql_main_categories = $hh->db_get("*","categories","type=1");
												while($main_categories = $hh->fetch_array($sql_main_categories)){
													?>
													<optgroup style="font-size:15px;" label="<?php echo $main_categories["category_name"]; ?>">
														<?php
														$sql_sub_categories = $hh->db_get("*","categories","type=2 AND parent=".$main_categories["id"]);
														while($sub_categories = $hh->fetch_array($sql_sub_categories)){
															?>
															<optgroup label="><?php echo $sub_categories["category_name"]; ?>">
															<?php
																$sql_sub_sub_categories = $hh->db_get("*","categories","type=3 AND parent=".$sub_categories["id"]);
																while($sub_sub_categories = $hh->fetch_array($sql_sub_sub_categories)){
																?>
																	<option <?php if((int)$_GET["category"] == $sub_sub_categories["id"]) echo "selected='selected'"; ?> value="<?php echo $sub_sub_categories["id"]; ?>">>><?php echo $sub_sub_categories["category_name"]; ?></option>
																<?php
																}
															?>
															</optgroup>
															<?php
														}
														?>
													</optgroup>
													<?php
												}
												?>
                                            </select>
                                            <br /><br />
                                            Şikayeti Yazarı : 
                                            <select  name="author" class="author">
                                            <option  <?php if($_GET["category"] == "all") echo "selected='selected'"; ?> selected="selected" value="all">Tümü</option>
                                            	<optgroup label="Adminler">
                                                <?php
													$sql_admins = $hh->db_get("*","users","authority=1");
													while($admins = $hh->fetch_array($sql_admins)){
													?>
                                                    	<option  <?php if((int)$_GET["author"] == $admins["id"]) echo "selected='selected'"; ?> value="<?php echo $admins["id"]; ?>"><?php echo $admins["username"]; ?></option>
                                                    <?php
													}
												?>
                                                </optgroup>
                                                <optgroup label="Editörler">
                                                <?php
													$sql_editors = $hh->db_get("*","users","authority=2");
													while($editors = $hh->fetch_array($sql_editors)){
													?>
                                                    	<option <?php if((int)$_GET["author"] == $editors["id"]) echo "selected='selected'"; ?> value="<?php echo $editors["id"]; ?>"><?php echo $editors["username"]; ?></option>
                                                    <?php
													}
												?>
                                                </optgroup>
                                                <optgroup label="Üyeler">
                                                <?php
													$sql_users = $hh->db_get("*","users","authority=3");
													while($users = $hh->fetch_array($sql_users)){
													?>
                                                    	<option <?php if((int)$_GET["author"] == $users["id"]) echo "selected='selected'"; ?> value="<?php echo $users["id"]; ?>"><?php echo $users["username"]; ?></option>
                                                    <?php
													}
												?>
                                                </optgroup>
                                            </select>
                                            <br /><br />
                                            Şikayet Edilen : 
                                            <input type="text" name="to_complaint" class="to_complaint"  <?php if($_GET["to_complaint"] != "") echo "value='".$_GET["to_complaint"]."'"; ?> />
                                            <br /><br />
                                            <input class="from_to" type="radio" name="from_to" id="from_to_new" <?php if($_GET["from_to"] == "from_to_new") echo "checked='checked'"; ?> value="from_to_new" />
                                            <label for="from_to_new">Yeniden eskiye</label>
                                            <input class="from_to" type="radio" name="from_to" id="from_to_old" value="from_to_old" <?php if($_GET["from_to"] == "from_to_old") echo "checked='checked'"; ?> />
                                            <label for="from_to_old">Eskiden yeniye</label> doğru<br /><br />
                                            <input type="submit" value="Filtreyi Uygula" />
                                            </form>
                                            </div>
                                            
                                            <div class="kma duz"></div>
                                                                            
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- konu bitiş -->
                                <!-- konu başlangıç -->
                                <div class="mesaj">
                                    
                                    <div class="kutu">
                                        <div class="kutumesaj">
                                            <div class="kmu"></div>
                                            
                                            <div class="kmo">
                                            
                                            <div class="kutubaslik">Şikayetler</div>
                                            	<?php 
													
													if(isset($_GET["block"])){
														if($_GET["block"] != "all"){
															$block = "block=".$hh->escape($_GET["block"]);
														}
														else
															$block = "";
													}
													else
														$block = "";
													
													if(isset($_GET["title"])){
														if($_GET["title"] != ""){
															$title = "title LIKE '%".$hh->escape($_GET["title"])."%'";
														}
														else
															$title = "";
													}
													else
														$title = "";
													
													if(isset($_GET["category"])){
														if($_GET["category"] != "all"){
															$category = "category=".$hh->escape($_GET["category"]);
														}
														else
															$category = "";
													}
													else
														$category = "";
														
													if(isset($_GET["author"])){
														if($_GET["author"] != "all"){
															$author = "author=".$hh->escape($_GET["author"]);
														}
														else
															$author = "";
													}
													else
														$author = "";
														
													if(isset($_GET["to_complaint"])){
														if($_GET["to_complaint"] != "" ){
															$to_complaint = "to_complaint LIKE '%".$hh->escape($_GET["to_complaint"])."%'";
														}
														else
															$to_complaint = "";
													}
													else
														$to_complaint = "";
													
													if(isset($_GET["from_to"])){
														if($_GET["from_to"] == "from_to_old")
															$from_to = "";
														elseif($_GET["from_to"] == "from_to_new")
															$from_to = "DESC";
													}
													else
														$from_to = "DESC";
														
													$var_arr = array($block, $title, $category, $author, $to_complaint);													
													
													foreach($var_arr as $key=>$val){
														if($key < 4){
															for($x = $key+1; $x <= 4; $x++){
																if($val != "" && $var_arr[$x] != ""){
																	$var_arr[$key] = $val." AND ";
																	break;
																}
															}
														}
													}
													
													$block = $var_arr[0];
													$title = $var_arr[1];
													$category = $var_arr[2];
													$author = $var_arr[3];
													$to_complaint = $var_arr[4];
													
													//
													if(isset($_GET["complaint_page"]))
														$complaint_page = $hh->escape($_GET["complaint_page"]);
													else
														$complaint_page = 1;
														
													$complaint_per_page = 10;
													//
														
													if($block == "" && $title == "" && $category == "" && $author == "" && $to_complaint == "")
													{
														$sql_complaints_for_page = $hh->db_get("*","complaints",1,"ORDER BY add_date $from_to");
														$sql_complaints = $hh->db_get("*","complaints",1,"ORDER BY add_date $from_to LIMIT ".(($complaint_page-1)*$complaint_per_page).", $complaint_per_page");
													}
													else{
														$sql_complaints_for_page = $hh->db_get("*","complaints",$block.$title.$category.$author.$to_complaint,"ORDER BY add_date $from_to");
														$sql_complaints = $hh->db_get("*","complaints",$block.$title.$category.$author.$to_complaint,"ORDER BY add_date $from_to LIMIT ".(($complaint_page-1)*$complaint_per_page).", $complaint_per_page");
													}
													//echo $block."<br>".$title."<br>".$category."<br>".$author."<br>".$to_complaint."<br>".$block.$title.$category.$author.$to_complaint;
													while($complaint = $hh->fetch_array($sql_complaints)){
														$auth = $hh->fetch_array($hh->db_get("username","users","id=".$complaint["author"]));
														$auth = $auth["username"];
														$sub_sub_cat = $hh->fetch_array($hh->db_get("*","categories","id=".$complaint["category"]));
														$sub_cat = $hh->fetch_array($hh->db_get("*","categories","id=".$sub_sub_cat["parent"]));
														$main_cat = $hh->fetch_array($hh->db_get("category_name","categories","id=".$sub_cat["parent"]));
														$category_a = $main_cat["category_name"].">>".$sub_cat["category_name"].">>".$sub_sub_cat["category_name"];
														if($complaint["block"] == 0)
															$block_a = "Aktif";
														elseif($complaint["block"] == 1)
															$block_a = "Engelli";
														elseif($complaint["block"] == 2)
															$block_a = "Onay için beklemede";
														?>
                                                        <div class="main_categories"><?php echo $hh->str_shorter($complaint["title"]); ?><a href="control.php?control=del_complaint_from_all_complaints&control2=<?php echo $complaint["id"]; ?>" class="complaint_del" title="Şikayeti Sil"><img src="images/design/del-button.png" alt="edit" /></a><a href="control.php?control=block_complaint&control2=<?php echo $complaint["id"]; ?>" style="color:#c00;" class="users_del" title="<?php if($complaint["block"]==0) echo "Engelle"; elseif($complaint["block"] == 1) echo "Aktif hale getir"; else echo "Onayla ve aktif hale getir"; ?>"><img src="images/design/<?php if($complaint["block"]==0) echo "block-logo"; else echo "activate-logo"; ?>.png" alt="block" /></a><a href="index.php?page=panel&panel=new_complaint&edit=<?php echo $complaint["id"]; ?>" class="users_edit" title="Düzenle"><img src="images/design/edit-button.png" alt="edit" /></a><img class="users_info" src="images/design/info.png" title="Şikayet Bilgileri" alt="<?php echo $complaint["title"]."--|--".$category_a."--|--".$auth."--|--".$complaint["to_complaint"]."--|--".$block_a."--|--".$hh->reverse_date($complaint["add_date"])."--|--".round($complaint["vote"],1)."--|--".$complaint["vote_count"]."--|--".$complaint["comment_count"]."--|--".$complaint["read_count"]; ?>" /></div>
                                                        <?php
													}
													
													$complaint_count = $hh->num_rows($sql_complaints_for_page);
													if($complaint_count > 0)
														$complaint_count = $complaint_count-1;
													else
														$complaint_count = 0;
														
													$page_count = (($complaint_count - ($complaint_count%$complaint_per_page)) / $complaint_per_page) + 1;
													?>
													<div class="clear"></div>
                                            </div>
                                            
                                            <div class="kma duz"></div>
                                                                            
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- konu bitiş -->
                                 <!-- sayfalama başlangıç -->
                                <div id="sayfalama">
                                    
                                <?php
                                    for($x = 1; $x <= $page_count; $x++){
                                    ?>
                                        <div class="sayfa"><a <?php if($x == $complaint_page){ ?>class="secili"<?php } ?> href="index.php?page=panel&panel=all_complaints&complaint_page=<?php echo $x; ?>"><?php echo $x; ?></a></div>
                                    <?php
                                    }
                                ?>
                                <div class="clear"></div>
                                </div>
                                <!-- sayfalama bitiş -->
                            <?php
							}
							break;
							
						}
					?>                    
                    	<!-- konu başlangıç -->
                        <!--
                    	<div class="mesaj">
                            
                            <div class="kutu">
                                <div class="kutumesaj">
                                    <div class="kmu"></div>
                                    
                                    <div class="kmo">
                                    
                                    <div class="kutubaslik">HASTA HAKKI'NDA KİMLER YAZI YAZABİLİR?</div>
                                    
                                    12 Eylül 2011 Salı günü eşimin yüksek ateş ve bademcik iltihaplanması şikayeti için Çakmaktaki Erdem Hast...<br />
                                    <a href="#">Devamı...</a>
                                    </div>
                                    
                                    <div class="kma duz"></div>
                                                                    
                                </div>
                            </div>
                            
                        </div>
                        -->
                        <!-- konu bitiş -->
                                                
                        <div class="clear"></div>
                        
                        <!-- sayfalama başlangıç -->
                        <!--
                        <div id="sayfalama">
                        	<div class="sayfa"><a href="#">1</a></div>
                            <div class="sayfa"><a href="#">2</a></div>
                            <div class="sayfa"><a class="secili" href="#">3</a></div>
                            <div class="sayfa"><a href="#">4</a></div>
                            <div class="clear"></div>
                        </div>
                        -->
                        <!-- sayfalama bitiş -->
                    
                    </div>
                </div>
            </div>
            
            
            <?php include("inner_right.php"); ?>
            <div class="clear"></div>
        </div>
        
        <div class="clear"></div>
        
        <?php include("footer.php"); ?>
    </div>

	<div class="clear"></div>
</div>


</body>
</html>
<?php
}
?>